//Controller κρατησης. Κανει κρατηση σε ενα καταστημα
package Controllers;

import DAO.Reservation_Dao;
import Exceptions.DaoException;
import Interfaces.IReservation_Dao;
import Models.Reservation;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;

public class Reservation_Controllers {

    Reservation_Controllers(Reservation_Dao reservation_Dao) {

    }

    public boolean Validate(String Name, String LastName, String PhoneNumber, String SeatNumber, String dateString)
            throws IllegalArgumentException, DaoException {
        boolean x = true;
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        String dtStr = dateString.trim();
        Date date = null;
        try {
            date = df.parse(dtStr);
        } catch (ParseException e) {
            //throw new IllegalArgumentException("Incorrect date format");
        }

        if (Calendar.getInstance().getTime().after(date)) {
            //throw new IllegalArgumentException("Date has already passed");
        }

        if (Name.isEmpty() || LastName.isEmpty() || PhoneNumber.isEmpty() || SeatNumber.isEmpty()) {
            //JOptionPane.showMessageDialog(null, "Empty Field");
            x = false;

        } else if (PhoneNumber.matches("[0-9]+") == false) {
            //JOptionPane.showMessageDialog(null, "Wrong Phone");
            x = false;
        } else if (PhoneNumber.length() > 10 || PhoneNumber.length() < 10) {
            //JOptionPane.showMessageDialog(null, "Wrong Phone");
            x = false;
        } else if (SeatNumber.matches("[0-9]+") == false) {
            //JOptionPane.showMessageDialog(null, "Wrong Number of Seats");
            x = false;
        } else if (SeatNumber.length() > 10 || SeatNumber.length() < 10) {
            //JOptionPane.showMessageDialog(null, "Wrong Number of Seats");
            x = false;

        }
        return x;

    }

}
